// 路由实现
const handler = require('../network/handler')

module.exports = function router(req, res) {
  if (req.url.startsWith('/index') || req.url === '/') {
    handler.getIndex(req, res);

  } else if (req.url.startsWith('/add')) {
    handler.sendPage('/pages/add.html', res)

  } else if (req.url.startsWith('/assets')) {
    handler.sendPage(req.url, res)

  } else if (req.url.startsWith('/delete')) {
    handler.delData(req, res)

  } else if (req.url.startsWith('/submit') && req.method === 'POST') {
    handler.subPost(req, res)

  } else if (req.url.startsWith('/submit') && req.method === 'GET') {
    handler.subGet(req, res)

  } else {
    handler.get404(req, res)
  }

}